% rebase('tpls/base.tpl')
<div style="width:1002px;background-color:#CE9;">
    %if name:
    你好，{{name}}<a href="/logout">退出</a> 
    %if usertype==1:
    <a href="/mgr_sbjcts">管理学习主题</a>
    %end
    %else:
        <form action="" method="POST" >
        <input type="hidden" name="sid" value="{{sid}}" />
        姓名：<input type="text" name="name"  />
        密码：<input type="password" name="psswd" />
        验证：<input type="text" name="verify_text" />
        <img src="/verify" />
        <input type="submit" value="登录" />
        <a href="/signup">注册</a>
        </form>
    %end
</div>
<div style="width:1202px;margin:0 auto;">
<div style="width:380px;height:500px;float:left;margin:0 10px;border:1px #EEE solid;">
    <h3>学习主题</h3>
    %for sbjct in sbjcts:
    <ul>
        <li><a href="/{{sbjct[0]}}">{{sbjct[1]}}</a></li>
    </ul>
    %end
</div>
<div style="width:570px;height:500px;float:left;margin:0 10px;border:1px #EEE solid;">
    <h3>{{current_sbjct[1]}}</h3>
    <p>{{current_sbjct[2]}}</p>
    %if name:
        %if self_answr:
        <h4>我的答案：</h4>
        <p>{{self_answr[3]}}</p>
        %end
        <form action="/add_qstn" method="post">
            <input type="hidden" name="sid" value="{{current_sbjct[0]}}" />
            <input type="hidden" name="id" value="{{id}}" />
            <textarea name="answr"></textarea>
            <input type="submit" value="提交答案" />
        </form>
    %end
</div>
<div style="width:180px;height:500px;float:right;margin:0 10px;border:1px #EEE solid;">
    <h3>互动讨论区</h3>
    %if name:
    <h4>我要提问：</h4>
    <form action="/ask_help" method="post">
    <input type="hidden" name="sid" value="{{sid}}" />
    <input type="text" name="qstn" />
    <input type="hidden" name="id" value="{{id}}" />
    <input type="submit" value="提问" />
    </form>
    %end
    %if askhlps:
        %for askhlp in askhlps:
            <h4>{{askhlp[0][4]}}:{{askhlp[0][2]}}</h4>
            %for answr in askhlp[1]:
                <p>{{answr[2]}}:{{answr[1]}}</p>
            %end
            %if name:
                <form action="/add_answr" method="POST">
                <input type="hidden" name="sid" value="{{sid}}" />
                <input type="hidden" name="id" value="{{id}}" />
                <input type="hidden" name="ask_id" value="{{askhlp[0][0]}}" />
                <input type="text" name="answr" />
                <input type="submit" value="回答" />
                </form>
            %end
        %end
    %end
</div>
</div>